Skip to content

feat(supabase): run the typed function calls through the client interceptors - #2056

Merged
spydon merged 2 commits into
mainfrom
lukasklingsbo/interceptor-rpc
Oct 26, 2026
Merged

spydon merged 2 commits into
mainfrom
lukasklingsbo/interceptor-rpc

Conversation

@spydon

@spydon spydon commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What

Stacked on #1940.

The typed function calls on client.rpc, rows and value and the methods supabase_typegen generates on top of them, already collect a PostgrestTableRequest with PostgrestTableOperation.rpc. However, they always sent it through a fresh PostgrestHttpTableExecutor, so the interceptors from #1940 never saw them. They now run through the same executor chain as table(). That means an interceptor such as an offline layer can cache, queue or answer function calls as well as table requests.

The untyped client.rpc('fn') keeps bypassing the interceptors, the same way from() does.

postgrest

  • PostgrestRpc takes an optional executor that rows and value run through, and withExecutor returns a copy that uses another one. Both are @internal, so no public surface is added. Without an executor it behaves exactly as before.

supabase

  • SupabaseClient.rpc and SupabaseQuerySchema.rpc hand the interceptor-wrapped executor to PostgrestRpc. Schema scoping is unchanged because the request carries its schema, as it does for tables.
  • wrapTableExecutor documents what a function call request looks like to an interceptor: it counts as a mutation unless readOnly is set, its table has no primary key, and a call read as a value has no rows. It also says that typed requests an interceptor makes on the client pass through the chain again, so the interceptor should use inner to bypass it.
  • The dartdocs of PostgrestTableExecutor, SupabaseClientInterceptor, SupabaseClient and rpc, plus MIGRATION.md and AGENTS.md, now say which calls pass through interceptors.

Tests

packages/supabase/test/client_interceptor_test.dart covers:

  • rpc.rows with a filter and rpc.value reaching the interceptor as rpc requests, with the filter and apikey on the wire.
  • A schema scoped call through the interceptor that carries Content-Profile.
  • A read-only call (get: true) reaching the interceptor with readOnly set and going out as a GET.
  • A header change reaching typed function calls through the interceptor chain.
  • The untyped rpc('ping') still bypassing the interceptor.

Summary by CodeRabbit

  • New Features
    • Typed RPC calls now pass through the client’s configured interceptors, including calls that return rows or scalar values. Interceptors can apply to request details such as headers, schema, and query arguments.
  • Documentation
    • Clarified that untyped RPC calls, like untyped table requests, bypass interceptors.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4efd670 and 4190b69.

Files selected for processing: 8
  • AGENTS.md
  • MIGRATION.md
  • packages/postgrest/lib/src/postgrest_rpc.dart
  • packages/postgrest/lib/src/postgrest_table_executor.dart
  • packages/supabase/lib/src/supabase_client.dart
  • packages/supabase/lib/src/supabase_client_interceptor.dart
  • packages/supabase/lib/src/supabase_query_schema.dart
  • packages/supabase/test/client_interceptor_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Walkthrough

Typed RPC calls now use the shared PostgREST executor. Supabase passes its interceptor-wrapped executor to typed RPC calls. Tests cover row and scalar results, schema headers, read-only GET requests, query arguments, and custom headers.

Changes: Typed RPC Interceptor Routing

Layer / File(s) Summary
Typed RPC executor support
packages/postgrest/lib/src/postgrest_rpc.dart, packages/postgrest/lib/src/postgrest_table_executor.dart
PostgrestRpc accepts an optional executor and uses it for typed rows and value calls. withExecutor returns a copy with the supplied executor while retaining the client and schema settings.
Supabase RPC routing and validation
packages/supabase/lib/src/supabase_query_schema.dart, packages/supabase/lib/src/supabase_client_interceptor.dart, packages/supabase/lib/src/supabase_client.dart, packages/supabase/test/client_interceptor_test.dart, AGENTS.md, MIGRATION.md
SupabaseQuerySchema.rpc supplies the wrapped executor. Documentation distinguishes typed RPC interception from untyped RPC bypass. Tests cover typed RPC interception and outgoing request properties.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant SupabaseQuerySchema
  participant PostgrestRpc
  participant SupabaseClientInterceptor
  participant PostgrestHttpTableExecutor
  SupabaseQuerySchema->>PostgrestRpc: supply wrapped executor
  PostgrestRpc->>SupabaseClientInterceptor: execute typed RPC request
  SupabaseClientInterceptor->>PostgrestHttpTableExecutor: forward request through inner executor
Loading

Possibly related PRs

Suggested labels: postgrest

Merge Risk: Minimal · up to 4190b

No actionable issue remains from the supplied evidence; the change is mergeable after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: typed function calls (rpc) now run through the Supabase client interceptors. The changeset matches this. It adds an optional executor to PostgrestRpc, routes SupabaseC…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: typed function calls (rpc) now run through the Supabase client interceptors. The changeset matches this. It adds an optional executor to PostgrestRpc, routes SupabaseClient and SupabaseQuerySchema rpc calls through the interceptor-wrapped executor, documents the behavior, and adds tests. The title uses the conventional feat(supabase) prefix and is 76 characters long. It omits the untyped rpc bypass and the read-only GET behavior, which is acceptable for a title.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (8 skipped: 8 unsupported.)

Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Base automatically changed from lukasklingsbo/client-plugins to main October 26, 2026 13:35
@spydon
spydon force-pushed the lukasklingsbo/interceptor-rpc branch from 4573ac3 to 4190b69 Compare October 26, 2026 13:36
@spydon
spydon merged commit 60f8267 into main Oct 26, 2026
47 checks passed
@spydon
spydon deleted the lukasklingsbo/interceptor-rpc branch October 26, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant